package com.reborn.mall.api.controller;

import com.reborn.mall.api.model.dto.ProductDTO;
import com.reborn.mall.api.model.entity.Product;
import com.reborn.mall.api.model.qo.ProductQO;
import com.reborn.mall.api.model.vo.ProductVO;
import com.reborn.mall.api.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品表-Controller
 *
 * @author wu.yue
 * @since 2020/1/23
 */
@RestController
@RequestMapping("/products")
public class ProductController extends BaseController<Product> {

    @Autowired
    private ProductService productService;

    @PostMapping("/create")
    public int createProduct(@ModelAttribute ProductDTO productDTO) {
        return productService.createProduct(productDTO);
    }

    @PostMapping("/details")
    public ProductVO getProductDetails(@RequestBody ProductQO productQO) {
        return productService.getProductDetails(productQO.getId());
    }
}
